package com.example.schooljava.mapper;

import com.example.schooljava.pojo.entity.Route;
import com.example.schooljava.pojo.entity.Teacher;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.schooljava.pojo.bo.StudentsOfClassBO;
import com.example.schooljava.pojo.bo.StudentsScoreOfClassBO;
import com.example.schooljava.pojo.bo.TeachersBO;
import com.example.schooljava.pojo.vo.AllScoreVO;
import com.example.schooljava.pojo.vo.OneScoreVO;
import com.example.schooljava.pojo.vo.StudentsOfClassVO;
import com.example.schooljava.pojo.vo.TeachersOfClassVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author LDH
 * @since 2022/08/11
 */
@Mapper
public interface TeacherMapper extends BaseMapper<Teacher> {
    /**
     * 功能描述: 班主任查询学生姓名，性别，年龄，和各科总成绩<br>
     * @Return: java.util.List<java.lang.Object>
     * @Author: LDH
     * @Date: 2022/8/12 16:55
     */
    List<AllScoreVO> findAllScore(StudentsOfClassBO studentsOfClassBO);

    /**
     * 功能描述: 班主任查询学生姓名，性别，年龄，和各科成绩<br>
     * @Return: java.util.List<java.lang.Object>
     * @Author: LDH
     * @Date: 2022/8/12 16:55
     */
    List<OneScoreVO> findOneScore(StudentsOfClassBO studentsOfClassBO);

    /**
     * 功能描述: 班主任查询本班级的科任老师<br>
     * @Return: java.util.List<java.lang.Object>
     * @Author: LDH
     * @Date: 2022/8/12 16:55
     */
    List<TeachersOfClassVO> getTeacherList(@Param("teacher") Long teacher);

    /**
     * 功能描述: 科任老师查询自己有教的班级的学生成绩<br>
     * @Return: java.util.List<java.lang.Object>
     * @Author: LDH
     * @Date: 2022/8/12 16:55
     */
    List<StudentsOfClassVO> getStudentOfCurr(StudentsOfClassBO studentsOfClassBO);

    /**
     * 功能描述: 科任老师查询自己有教的  年级<br>
     * @Return: java.util.List<java.lang.Object>
     * @Author: LDH
     * @Date: 2022/8/12 16:55
     */
    @Select("SELECT class.grade\n" +
            "FROM class_curr,class\n" +
            "WHERE teacherid=#{taacherid}  AND classid=class.id")
    List<Integer> getGrade(@Param("taacherid") Long teacherid);

    /**
     * 功能描述: 科任老师查询自己有教的  班级<br>
     * @Return: java.util.List<java.lang.Object>
     * @Author: LDH
     * @Date: 2022/8/12 16:55
     */
    @Select("SELECT class.name\n" +
            "FROM class_curr,class\n" +
            "WHERE teacherid=#{taacherid}  AND classid=class.id AND grade=#{grade}")
    List<String> getClassName(@Param("taacherid") Long teacherid, @Param("grade") Integer grade);

    /**
     * 功能描述: 学校管理人员查看所有教师<br>
     * @Return: java.util.List<java.lang.Object>
     * @Author: LDH
     * @Date: 2022/8/12 16:55
     */
    List<Teacher> getTeacher(TeachersBO teachersBO);

    /**
     * 功能描述: 班级助理查询本班的成绩<br>
     * @Param: [query]
     * @Return: java.util.List<com.example.schooljava.entity.Student>
     * @Author: LDH
     * @Date: 2022/8/19 9:33
     */
    List<OneScoreVO> getStudentScoreOfClass(StudentsScoreOfClassBO studentsScoreOfClassBO);

    /**
     * 功能描述: 获取身份权限路由<br>
     * @Param: []
     * @Return: java.util.List<com.example.schooljava.entity.Route>
     * @Author: LDH
     * @Date: 2022/8/23 9:27
     */
    @Select("SELECT distinct route.id, pid, path, route.name, link, title\n" +
            "FROM role_route, route, teacher, user_role, role\n" +
            "WHERE tno=user_role.userid\n" +
            "AND tno=#{tno}\n" +
            "AND user_role.roleid=role.id\n" +
            "AND role.id=role_route.roleid\n" +
            "AND role_route.routeid = route.id")
    List<Route> getRoute(@Param("tno") Long tno);

    @Select("SELECT name\n" +
            "FROM user_role, role\n" +
            "WHERE userid=#{tno} AND roleid=role.id")
    String[] getRole(@Param("tno") Long tno);
}
